package com.xgst.land.utils

import com.blankj.utilcode.util.LogUtils
import com.blankj.utilcode.util.TimeUtils
import java.util.Calendar

object WeekDayUtils {
    fun getWeekDayList(list:(List<Long>,weekNumber:Int) -> Unit){
        // 存放每一天时间的集合
        val weekMillisList: MutableList<Long> = ArrayList()
        var nowDateMill = TimeUtils.getNowMills()
        // Calendar
        val calendar = Calendar.getInstance()
        calendar.timeInMillis = nowDateMill
        // 本周的第几天
        val weekNumber = calendar[Calendar.DAY_OF_WEEK]
        // 获取本周一的毫秒值   86400000是一天的毫秒值
        var mondayMill: Long
        if(weekNumber == 1){
            mondayMill = nowDateMill - 86400000 * 6
        }else{
            mondayMill = nowDateMill - 86400000 * (weekNumber - 2)
        }
        for (i in 0..6) {
            weekMillisList.add(mondayMill + 86400000 * i)
        }
        list(weekMillisList,weekNumber)
    }
}